﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace DongFangGuoKai.TaskPlatform.WebApi.Utility.Filter
{
    public class CtmExcepitonFilterAttribute : Attribute, IAsyncExceptionFilter
    {
        public async Task OnExceptionAsync(ExceptionContext context)
        {
            if (!context.ExceptionHandled)
            {

                context.Result = new JsonResult(new 
                {
                    Code = "500",
                    Message = context.Exception.Message,
                    Success = false
                });


            }

            context.ExceptionHandled = true;
            await Task.CompletedTask;
        }
    }
}
